package com.hiwetop.cp;

import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;
import java.util.Arrays;
import java.util.List;

/**
 * Created by linyu on 2016/12/22.
 */
public class Code {
    public static void main(String[] args) {
        File file = new File("code.png");
        Tesseract tessreact = new Tesseract();
        tessreact.setDatapath(new File("D:\\develop\\running\\workspace_idea\\aliyun\\tessdata").getPath());
        String expResult = "[-0123456789.\n ]+";
        List<String> configs = Arrays.asList("digits");
        tessreact.setConfigs(configs);
        try {
            String result = tessreact.doOCR(file);
            System.out.println(result);
        } catch (TesseractException e) {
            System.err.println(e.getMessage());
        }
    }
}
